package com.szwistar.common.comm;

import java.net.SocketAddress;

import com.szwistar.common.datastruct.Utils;

public class BytesAddress extends SocketAddress {
	private static final long serialVersionUID = -5387370292286134221L;
	byte[] bytes;

	public BytesAddress(byte[] bytes) {
		super();
		this.bytes = bytes;
	}

	public BytesAddress(byte[] bytes, int offset, int length) {
		super();
		setBytes(bytes, offset, length);
	}

	public byte[] getBytes() {
		return bytes;
	}

	public void setBytes(byte[] bytes) {
		this.bytes = bytes.clone();
	}

	public void setBytes(byte[] bytes, int offset, int length) {
		this.bytes = new byte[length];
		System.arraycopy(bytes, offset, this.bytes, 0, length);
	}

	@Override
	public String toString() {
		return Utils.bytesToHexString(bytes);
	}
}
